var setHook = (function () {
    function doSomeThing(attr, doSomeThings) {
        var tempFunction = this[attr];
        var that = this;
        this[attr] = function () {
            doSomeThings.apply(that, Array.prototype.slice.call(arguments));
            return tempFunction.apply(that, Array.prototype.slice.call(arguments));
        }
    }
    function setHook(obj, attr, doSomeThings) {
        doSomeThing.call(obj, attr, doSomeThings);
    }
    return setHook;
})()


setHook($, "ajaxSetup", function () {
    var settings = arguments[1];
    var isHook = settings.isHook;
    var url = settings.url;
    settings = baseUrl + settings.url;
    if (isHook) {
        if (settings.success) {
            setHook(settings, 'success', function (res) {
                console.log(res);
                if (res.state) {
                    layer.msg('操作成功', {icon: 1});
                } else {
                    layer.msg(getMsg(res.code), {icon: 5});
                }
            })
        }
        if (settings.error) {
            setHook(settings, 'error', function () {
                layer.msg('程序错误，请反馈', {icon: 5});
            })
        }
    }
})

